package com.mxpio.erp.common.technology.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.jpa.policy.impl.UUIDPolicy;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INVENTORY_ITEM_DESIGN_FILE")
@Schema(description="产品设计图档")
public class ItemDesignFile extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@Generator(policy = UUIDPolicy.class)
	@Column(name = "ID_")
	@Schema(description = "主键")
	private String id;

	@Column(name = "ITEM_CODE_")
	@Schema(description = "产品(物料)编码")
	private String itemCode;

	@Column(name = "FILE_NO_")
	@Schema(description = "附件")
	@Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
	private String fileNo;

	@Column(name = "FILE_NAME_")
	@Schema(description = "文件名称")
	private String fileName;

	@Column(name = "VERSION_")
	@Schema(description = "版本")
	private Integer version=1;

	@Column(name = "LENGTH_")
	@Schema(description = "文件大小")
	private long length;

	@Column(name = "EDITION_")
	@Schema(description = "版次")
	private Integer edition = 1;

	@Column(name = "REMARKS_")
	@Schema(description = "文件描述")
	private String remarks;

	@Column(name = "EXTENSION_")
	@Schema(description = "文件扩展名")
	private String extension;

	@Column(name = "FALIMY_",updatable = false)
	@Schema(description = "文件家族标志")
	private String family;

	@Column(name = "PRIMARY_")
	@Schema(description = "生效标识")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String primary = "1";

	@Column(name = "OPERATE_STATUS_" )
	@Schema(description = "是否签出操作")
	@Dict(dicCode = "ERP_COMMON_YESNO")
	private String  signOffFlag = "0";

	@Column(name = "SIGNOFFER_")
	@Schema(description = "签出人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String signOffer;

	@Column(name = "SIGN_OFF_TIME_")
	@Schema(description = "签出时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date signOffTime;

	@Column(name = "SIGNINER_")
	@Schema(description = "签入人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String signIner;

	@Column(name = "SIGN_IN_TIME_")
	@Schema(description = "签入时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date signInTime;

	@Column(name = "SIGN_IN_DESC_")
	@Schema(description = "签入说明")
	private String signInDesc;

	@Column(name = "SIGN_IN_CODE_")
	@Schema(description = "签入单号")
	private String signInCode;

	@Column(name = "CHANGER_")
	@Schema(description = "变更人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String changer;

	@Column(name = "CHANGE_TIME_")
	@Schema(description = "变更时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date changeTime;

	@Column(name = "CHANGE_CODE_")
	@Schema(description = "变更单单号")
	private String changeCode;
	@Transient
	private ItemDesignFileAlter alter;

	@Transient
	private ItemDesignFileSignIn signIn;

	public void setSignInCode(String code) {
	}
}
